<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="mvc" uri="http://www.trkj.com/mvc/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>地址管理</title>
<link type="text/css" href="css/haddress.css" rel="stylesheet" ></link>
<link rel="stylesheet" href="css/cityLayout.css" />
<style type="text/css">
.newadd{
		width:160px;
				height:40px;
				color:white;
				border:1px solid #E01D20;
				background:url(image/地址.png) no-repeat 10px #E01D20;
				background-size:25px 25px;
				margin-left:20px;
				margin-top:20px;
	}
	.pad{
		margin-left:50px;
	}
	.diviframe{
				height:490px;
				width:350px;
				border-top:22px solid rgba(221,221,221,0.8);
				border-left:5px solid rgba(221,221,221,0.8);
				border-bottom:5px solid rgba(221,221,221,0.8);
				border-right:5px solid rgba(221,221,221,0.8);
				display: block;
				position: absolute;
				top:70px;
				left: 30%;
				border-radius:5px;
				background:white;
				padding-left:20px;
				margin-left:100px;
	}
	
	.city_input{
		height:30px;
		width:200px;
		border: 1px solid #DDDDDD;
	}
	.haddressjsp{
		padding-top:50px;
		height:570px;
	}
</style>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/jquery.animate-colors.js"></script>
<script type="text/javascript" src="js/cityselect.js"></script>
<script type="text/javascript">
$(function(){
	
	$(".newadd").click(function(){
		$(".newaddress").show();
	});
	$(".tijiao2").click(function(){
		$(".newaddress").hide();
		//清空input框中的信息
		$(".newaddress input:text").val("");
	});
	$(".guanbi").click(function(){
		$(".newaddress").hide();
		//清空input框中的信息
		$(".newaddress input:text").val("");
	});
		
	//设置tr背景色偶数为#FAFAFA
	$(".table2").find("tr:odd").css("background-color", "#FAFAFA");	
	
	//删除操作
	$(".reciver_delete").click(function(){
		if(confirm("确认删除？")){
			var a=$(this);
			$.get("reciver?action=deleteReciver", {id:a.attr("id")}, function(){
				a.parent().parent().remove();
			});
		}	
	});
	
	
	//点击查看修改内容
	$(".xiugai").click(function(){
		var a=$(this).parent().attr("id");
		$("#idform").attr("action","reciver?action=updateaddress");
		$.getJSON("reciver?action=selectReciver",{id:a},function(e){
			$("#xingming").val(e.r_name);
			$(".city_input").val(e.a_name);
			$("#shuru1").val(e.address);
			$("#shuru2").val(e.tel);
			$("#shuru3").val(e.phone);
			$("#shuru4").val(e.zip_code);
			$(".newaddress").show();			
		});		
	});
	

	init_city_select($("#citySelect"));

});
</script>
</head>
<body>
<div ><%@include file="chead.jsp" %></div>
<div class=" haddressjsp">
	<div style="float:left"><%@include file="hppmenu.jsp" %></div>
	<div class="dindanhezi">
		<div class="dindan">
			<span>地址管理</span>	
		</div>
	</div>
		<table class="table2" width="1000px" height="150px">
				<thead>
					<tr>
						<th>收货人</th>
						<th>所在地区</th>
						<th>街道地址</th>
						<th>电话/手机</th>
						<th>邮编</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${list }" var="u" varStatus="vs">
						<tr>
							<td>${u.r_name}</td>
							<td>${u.a_name}</td>
							<td>${u.address}</td>
							<td>${u.phone }</td>
							<td>${u.zip_code}</td>
							<td id="${u.id}">
								<a class="xiugai" href="javascript:void(0);" ><img class="picture1" src="image/点评.png"/></a>|
								<a id="${u.id}" class="reciver_delete" href="javascript:void(0);"><img class="picture2" src="image/删除.png"/></a>|
								<a id="${u.id}" class="morena" href="reciver?action=updatedefault0&&id=${u.id }">${u.state}</a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<input class="newadd" type="submit" value="添加新地址">
		<div class="newaddress">
			<span class="shouhuo">收货地址</span><p/>
			<img class="guanbi" src="image/关闭.png">
			<form action="reciver?action=addaddress" method="post" id="idform">
				<ul class="uu">
					<li>
						<span>姓名：</span>
						<input  type="text" class="shuru" id="xingming" name="rname"/><p/>
					</li>
					<li>
						<span>省份：</span>
						<input id="citySelect" name="citySelect" type="text" class="city_input" > 
					</li>
					<li>
						<span>地址：</span>
						<input  type="text" class="shuru" id="shuru1" name="addres"/><p/>
					</li>
					<li>
						<span>手机：</span>
						<input  type="text" class="shuru" id="shuru2" name="shouji"/><p/>
					</li>
					<li>
						<span>固话：</span>
						<input  type="text" class="shuru" id="shuru3" name="guhua"/><p/>
					</li>
					<li>
						<span>邮编：</span>
						<input  type="text" class="shuru" id="shuru4" name="youbian"/><p/>
					</li>
					<li>
						<input type="submit" value="提交" class="tijiao1"/>
						<input type="button" value="取消" class="tijiao2"/>
					</li>
				</ul>
			</form>
		</div>
</div>	
<div style="margin-top:50px;" ><%@include file="cfooter.jsp" %></div>
</body>
</html>